package org.softee.messaging.processor;

import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FilterProcessor implements Processor {
    private final Pattern contains;

    public FilterProcessor(String containsPattern) {
        this.contains = Pattern.compile(containsPattern);
    }

    @Override
    public List<String> process(String message) {
        Matcher matcher = contains.matcher(message);
        if (matcher.find()) {
            return Collections.singletonList(message);
        } else {
            return Collections.emptyList();
        }
    }
}